import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const router = new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'Login',
      component: () => import('../views/Login'),
    },
    {
      path: '/logon',
      name: 'logon',
      component: () => import('../views/logon'),
    },
    {
      path: '/studentCode',
      name: 'studentCode',
      component: () => import('../views/studentCode'),
    },
    {
      path: '/home',
      name: 'home',
      component: () => import('../views/Home'),
      children: [
        {path: '/guidanceResources',  name: 'guidanceResources', component: () => import("../pages/guidanceResources")},
        {path: '/evaluationManagement',  name: 'evaluationManagement', component: () => import("../pages/evaluationManagement")},
        {path: '/experiment',  name: 'experiment', component: () => import("../pages/experiment")},
        {path: '/prescription',  name: 'prescription', component: () => import("../pages/prescription")},
        {path: '/userData',  name: 'userData', component: () => import("../components/userData")},
        {path: '/setting',  name: 'setting', component: () => import("../components/setting")},
        {path: '/experimentalEvaluation',  name: 'experimentalEvaluation', component: () => import("../components/student/experimentalEvaluation")},
        {path: '/studentAnswer',  name: 'studentAnswer', component: () => import("../components/student/studentAnswer")},
        {path: '/experimentalGuidance',  name: 'experimentalGuidance', component: () => import("../components/student/experimentalGuidance")},
        {path: '/experimentalTraining',  name: 'experimentalTraining', component: () => import("../components/student/experimentalTraining")},
        {path: '/laboratoryAnnouncement',  name: 'laboratoryAnnouncement', component: () => import("../components/student/laboratoryAnnouncement")},
        {path: '/adminNotice',  name: 'adminNotice', component: () => import("../components/admin/adminNotice")},
        {path: '/adminGuidelines',  name: 'adminGuidelines', component: () => import("../components/admin/adminGuidelines")},
        {path: '/adminTrain',  name: 'adminTrain', component: () => import("../components/admin/adminTrain")},
        {path: '/adminEvaluation',  name: 'adminEvaluation', component: () => import("../components/admin/adminEvaluation")},
        {path: '/systemCase',  name: 'systemCase', component: () => import("../components/admin/systemCase")},
        {path: '/studentCase',  name: 'studentCase', component: () => import("../components/admin/studentCase")},
        {path: '/teacherManage',  name: 'teacherManage', component: () => import("../components/admin/teacherManage")},
        {path: '/studentManage',  name: 'studentManage', component: () => import("../components/admin/studentManage")},
        {path: '/laboratoryManage',  name: 'laboratoryManage', component: () => import("../components/admin/laboratoryManage")},
        {path: '/questionPage',  name: 'questionPage', component: () => import("../components/admin/questionPage")},
        {path: '/questionEdit',  name: 'questionEdit', component: () => import("../components/admin/questionEdit")},
        {path: '/two',  name: 'two', component: () => import("../components/admin/two")},
        {path: '/answerStuation',  name: 'answerStuation', component: () => import("../components/admin/answerStuation")},
        {path: '/solution',  name: 'solution', component: () => import("../components/admin/solution")},
        {path: '/commentDetails',  name: 'commentDetails', component: () => import("../components/admin/commentDetails")},
        {path: '/classManage',  name: 'classManage', component: () => import("../components/admin/classManage")},
        {path: '/log',  name: 'log', component: () => import("../components/admin/log")},
        {path: '/train',  name: 'train', component: () => import("../components/student/train")},
        {path: '/caseCategory',  name: 'caseCategory', component: () => import("../components/admin/caseCategory")},
        {path: '/caseCategoryTwo',  name: 'caseCategoryTwo', component: () => import("../components/admin/caseCategoryTwo")},
        {path: '/caseCategoryThere',  name: 'caseCategoryThere', component: () => import("../components/admin/caseCategoryThere")},
        {path: '/caseInquiry',  name: 'caseInquiry', component: () => import("../components/student/caseInquiry")},
        {path: '/myCase',  name: 'myCase', component: () => import("../components/student/myCase")},

      ]
    }
  ]

})
// 导航守卫
// 使用 router.beforeEach 注册一个全局前置守卫，判断用户是否登陆
// router.beforeEach((to, from, next) => {
//   if (to.path === '/') {
//     next()
//   } else {
//     const token = window.sessionStorage.getItem('token')
//     if (!token) {
//       next('/')
//     } else {
//       next()
//     }
//   }
// })

export default router
